<?php
//include '../../common.inc.php';
//$hd = new ImportLoop();
//$hd->setAim('mysql:host=192.168.1.19;dbname=ixdcw', 'root', 'root');

$file = "D:\\采集\\21世纪房车网\\国际新闻\\SpiderResult.mdb";
$file = iconv('utf-8', 'gbk', $file);
$dh = new PDO("odbc:Driver={Microsoft Access Driver (*.mdb)};Dbq=$file;");
$ds = $dh->query("select id, title from content where id=5");
$fo = $ds->fetchAll();
var_dump($fo);
exit();


$hd->setSource("odbc:Driver={Microsoft Access Driver (*.mdb)};Dbq=$file;", '', '');
$hd->setSourceInfo('content', 'id', '');
$params = array(
	'maxid'     => isset($_GET['maxid']) ? $_GET['maxid'] : 0,
	'id'        => isset($_GET['id']) && !empty($_GET['id']) ? $_GET['id'] : 0,
	'startTime' => isset($_GET['startTime']) ? $_GET['startTime'] : time(),
	'limit'     => 20,
	'interval'  => 1,
	'debug'     => isset($_GET['debug']) ? $_GET['debug'] : 'xddl',
);
$hd->initParams($params);
var_dump($hd->getParams());
$str = "select top 10 from " . $hd->getSourceTable();
var_dump($str);
$ds = $hd->getDbSource()->query($str);
$fo = $ds->fetchAll();
var_dump($fo);
$sql = 'select max(*) as num from content';
var_dump($sql);
$result = $dbs->query($sql);
var_dump($result);
$rs     = $result->fetchAll();
var_dump($rs);
if (!$rs) {
	$hd->end();
} else {
	$carFolders = array();
	foreach ($rs as $k => $v) {
		$hd->setParam('id', $v['arid']);
		$carFolder    = AutoImport::carFolderByInfo($v);
		$carFolders[] = array($carFolder . '/公共属性', $v['parentid'], $v['arid'], 0);
		$models       = AutoModel::shortByCarid($v['arid']);
		if (empty($models)) {
			continue;
		} else {
			foreach ($models as $model) {
				$carFolders[] = array($carFolder . '/' . $model['name'], $v['parentid'], $v['arid'], $model['amid']);
			}
		}

	}
	$sql = "insert import_picture (folder, arbid, arcid, amid) values";
	$values = array();
	foreach($carFolders as $k => $va) {
		$values[] = '(\''.implode("','", $va).'\')';
	}
	$sql .= implode(',', $values);
	if ($hd->getDbAim()->query($sql)) {
		var_dump($v['arid'], $v['name'], $hd->times(), $hd->getParam('maxid'));
	} else {
		print_r($sql);
		exit();
	}
}
var_dump($hd->getParams());
echo $hd->start($hd->getParams());